package com.spx.core.wizards;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;

import com.spx.core.CoreActivator;
import com.spx.core.types.Role;

/**
 * This is a sample new wizard. Its role is to create a new file resource in the
 * provided container. If the container resource (a folder or a project) is
 * selected in the workspace when the wizard is opened, it will accept it as the
 * target container. The wizard creates one file with the extension "mpe". If a
 * sample multi-basic editor (also available as a template) is registered for
 * the same extension, it will be able to open it.
 */

public class NewRoleWizard extends NewModelObjectWizard<Role>
{

	private final ModelWizardPage<Role> basic;

	/**
	 * Constructor for NewUserWizard.
	 */
	public NewRoleWizard()
	{
		super();
		basic = new NewRolePage();

		pages.add(basic);

		setModelObject(new Role());
	}

	/**
	 * We will accept the selection in the workbench to see if we can initialize
	 * from it.
	 * 
	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
	 */
	@Override
	public void init(IWorkbench workbench, IStructuredSelection selection)
	{

	}

	@Override
	public void finish()
	{
		CoreActivator.getDefault().getSecurityService().addRole(this.getModelObject());
	}
}